object ActivityRegistrationSystem extends App {

  case class Student(
                      name: String,
                      major: String,
                      programmingScore: Int,
                      weeklyAvailableHours: Int,
                      hasFailedCourses: Boolean,
                      specialty: String,
                      grade: Int,
                      canAttendRehearsal: Boolean,
                      peScore: Int,
                      hasSeriousIllness: Boolean,
                      runningTime: Double
                    )


  val students = List(
    Student("张三", "计算机科学", 90, 15, false, "无", 3, false, 75, false, 4.5),
    Student("李四", "电子工程", 88, 8, false, "唱歌", 2, true, 82, false, 3.9),
    Student("王五", "中文", 65, 12, true, "跳舞", 1, true, 88, false, 3.5),
    Student("赵六", "机械工程", 78, 10, false, "乐器", 4, true, 76, true, 5.0),
    Student("孙七", "软件工程", 92, 12, false, "表演", 2, true, 85, false, 3.2)
  )


  def checkProgrammingContest(student: Student): (Boolean, String) = {
    // 条件1：专业或成绩
    if (student.major.contains("计算机") || student.programmingScore >= 85) {
      // 条件2：时间
      if (student.weeklyAvailableHours >= 10) {
        // 条件3：无挂科
        if (!student.hasFailedCourses) {
          (true, "符合所有条件")
        } else {
          (false, "不符合：有挂科记录")
        }
      } else {
        (false, "不符合：每周可投入时间不足10小时")
      }
    } else {
      (false, "不符合：非计算机相关专业且编程成绩<85")
    }
  }

  def checkArtPerformance(student: Student): (Boolean, String) = {
    // 条件1：有文艺特长
    val hasArtSpecialty = List("唱歌", "跳舞", "乐器", "表演").contains(student.specialty)
    if (hasArtSpecialty) {
      // 条件2：能参加排练
      if (student.canAttendRehearsal) {
        // 条件3：年级
        if (student.grade <= 2) {
          (true, "符合所有条件")
        } else {
          (false, "不符合：仅接受大一、大二学生")
        }
      } else {
        (false, "不符合：无法参加每周2次排练")
      }
    } else {
      (false, "不符合：无相关文艺特长")
    }
  }

  def checkAthleticsMeet(student: Student): (Boolean, String) = {
    // 条件1：体育成绩
    if (student.peScore >= 80) {
      // 条件2：无重大疾病
      if (!student.hasSeriousIllness) {
        // 条件3：体能要求
        if (student.runningTime <= 4.0) {
          (true, "符合所有条件")
        } else {
          (false, "不符合：1000米成绩超过4分钟")
        }
      } else {
        (false, "不符合：有重大疾病史")
      }
    } else {
      (false, "不符合：体育课程成绩<80")
    }
  }

  // 批量审核并输出结果
  for (student <- students) {
    println(s"\n===== 学生${student.name}的报名审核结果 =====")

    val (progOk, progReason) = checkProgrammingContest(student)
    println(s"编程大赛：${if (progOk) "通过" else "未通过"}（${progReason}）")

    val (artOk, artReason) = checkArtPerformance(student)
    println(s"文艺汇演：${if (artOk) "通过" else "未通过"}（${artReason}）")

    val (athOk, athReason) = checkAthleticsMeet(student)
    println(s"田径运动会：${if (athOk) "通过" else "未通过"}（${athReason}）")

    // 汇总可参加的活动
    val eligibleActivities = List(
      ("编程大赛", progOk),
      ("文艺汇演", artOk),
      ("田径运动会", athOk)
    ).filter(_._2).map(_._1)

    println(s"可参与的活动：${if (eligibleActivities.nonEmpty) eligibleActivities.mkString(", ") else "无"}")
  }
}